#subset on urban municipalities
brazil_data_tab <- brazil_data[brazil_data$urb == 1,]

#conventional standard errors
doc_mod_brazil <- lm(prop_doctos ~ log10(pop) + pop_growth + density + div_index + avg_salary_mo_2010 + ill_rate_2010 + elec_index + align, data = brazil_data_tab)
teach_mod_brazil <- lm(teachers_prop ~ log10(pop) + pop_growth + density + div_index + avg_salary_mo_2010 + ill_rate_2010 + elec_index + align, data = brazil_data_tab)
comm_mod_brazil <- lm(prop_comm_health ~ log10(pop) + pop_growth + density + div_index + avg_salary_mo_2010 + ill_rate_2010 + elec_index + align, data = brazil_data_tab)
schools_mod_brazil <- lm(schools_prop ~ log10(pop) + pop_growth + density + div_index + avg_salary_mo_2010 + ill_rate_2010 + elec_index + align, data = brazil_data_tab)
elec_mod_brazil <- lm(electr_share_2010 ~ log10(pop) + pop_growth + density + div_index + avg_salary_mo_2010 + ill_rate_2010 + elec_index + align, data = brazil_data_tab)
water_mod_brazil <- lm(piped_water_share_2010 ~ log10(pop) + pop_growth + density + div_index + avg_salary_mo_2010 + ill_rate_2010 + elec_index + align, data = brazil_data_tab)

table <- list(comm_mod_brazil, schools_mod_brazil,doc_mod_brazil, teach_mod_brazil, elec_mod_brazil, water_mod_brazil)

table <- stargazer(table,
                   label = 'tab:brazil1',
                   type = "html",
                   title = "Relationship Between City Size and Public Goods, Brazil",
                   dep.var.labels = c("Community Health Centers", "Schools", "Doctors", "Teachers",  "Electricity", "Water"),
                   covariate.labels = c("City Size (log(population))", "Growth (\\%, 2001-2011)",
                                        "Density (1000/km2)", "Racial Diversity Index", "Average Monthly Income", 
                                        "Illiteracy Rate",
                                        "Electoral Competition Index","Partisan Alignment (0/1)"),
                   star.cutoffs = c(0.05, 0.01, 0.001),
                   keep.stat = c("n"),
                   digits = 2,
                   notes = NULL,
                   add.lines = list(c("Cluster SE?", rep("No", 6)))
)

cat(table, sep = '\n', file = "./_4_outputs/table_a1.htm")

#clean up
rm(table, comm_mod_brazil, schools_mod_brazil,doc_mod_brazil, elec_mod_brazil, water_mod_brazil)